1. /* srffcomp.cpp by K.Tsuru */
  2. // function ID = 8001 BRADIX
  3. /****************************************************************
  4. SRational class
  5. return sgn(|m| - |n|) = 1, 0 , -1
  6. m = m.num/m.den; n = n.num/n.den;
  7. |m| - |n| = ( |m.num|*n.den - m.den*|n.num| ) / (m.den*n.den);
  8. ****************************************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. int RRCompare(const SRational& m, const SRational& n){
  13. //It checks the diffrence of figures.
  14. //99*99 (2+2) = 891*11 (3+2) : error is one figure
  15. int df;
  16. df = (int)(m.NumNR().Head()+n.DenNR().Head()) - int(m.DenNR().Head()+n.NumNR().Head());
  17. if(abs(df) > 1) return Sgn(df); //clearly diffrent
  18. SInteger a, b;
  19. a = m.NumNR()*n.DenNR(); b = m.DenNR()*n.NumNR();
  20. return LLCompare(a, b);
  21. }

srrrcomp.cpp : last modifiled at 2015/12/03 21:23:13(792 bytes)
created at 2016/06/26 15:57:35
The creation time of this html file is 2016/09/18 20:28:05 (Sun Sep 18 20:28:05 2016).